%  PARTISN FLUX PLOTTER
%  I load in the *.out file from my rtflux reader
dim = 2;


load 'lala.out'
poop=lala;

if dim == 1
    
    nx = sum(xfm);
    k=0;
    for g = 1:input.numg
        for i = 1:nx
            k=k+1;
            phiP(i,g) = poop(k,4);
        end
    end
    x = linspace(0,10,nx+1);
    xx = 0.5*(x(2:end)+x(1:end-1));
    
    subplot(2,1,1)
    
    semilogy(xx,phi(:,2),'k-',xx,phiP(:,2),'k-x','LineWidth',2)
    legend('\phi', '\phi^{bench}',  0) 
    xlabel(' x [cm]'), ylabel('\phi [n/cm^{-2}]')
    title('Benchmark comparison of 1-group fluxes')
    
    subplot(2,1,2)
    semilogy(xx,abs((phi(:,2)-phiP(:,2))./phiP(:,2)), 'k--', 'LineWidth',2)
     xlabel(' x [cm]'), ylabel('|(\phi-\phi^{bench})/\phi^{bench}|')
else
    
    nx = sum(xfm);
    ny = sum(yfm);
    k=0;
    for g = 1:input.numg
        for j = 1:ny
            for i = 1:nx
                k=k+1;
                phiP(i,j,g) = poop(k,4);
            end
        end
    end
    x = linspace(0,10,nx+1);
    xx = 0.5*(x(2:end)+x(1:end-1));
   subplot(2,1,1)
   semilogy(sqrt(2)*xx, diag(phi(:,:,1)), 'k-', sqrt(2)*xx, diag(phiP(:,:,1)),'k-x',...
            sqrt(2)*xx, diag(phi(:,:,2)), 'b-', sqrt(2)*xx, diag(phiP(:,:,2)),'b-o',...
       'LineWidth',2)
   legend('\phi_1', '\phi_1^{bench}', '\phi_2', '\phi_2^{bench}',  0)
   xlabel(' dist [cm]'), ylabel('\phi [n/cm^{-2}]')
   title('Benchmark comparison of 2-group fluxes')
   subplot(2,1,2)
   semilogy(sqrt(2)*xx,  abs( diag(phi(:,:,2)-phiP(:,:,2))./diag(phiP(:,:,2)))  ,'k--', ...
            sqrt(2)*xx,  abs( diag(phi(:,:,1)-phiP(:,:,1))./diag(phiP(:,:,1)))  ,'b-.','LineWidth',2)
    legend('err_1',  'err_2',   0)
   xlabel(' dist [cm]'), ylabel('|(\phi-\phi^{bench})/\phi^{bench}|')
end